<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="apple-mobile-web-app-title" content="阿福易购">
    <meta content="telephone=no" name="format-detection" />
    <meta content="email=no" name="format-detection" />
    <!-- uc、qq浏览器 -->
    <meta name="screen-orientation" content="portrait">
    <meta name="full-screen" content="yes">
    <meta name="browsermode" content="application">
    <meta name="x5-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="x5-page-mode" content="app">
    <meta name="HandheldFriendly" content="true">
    <meta name="MobileOptimized" content="320">
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>
    <title>阿福易购_首页_{{$SEO['title']}}</title>
    <link rel="stylesheet" href="{{ asset('/build/css/app.min.css') }}">
</head>

<body ontouchstart="">
<header class="ui-header ui-header-stable  af-header">
    <ul class="ui-row-flex">
        <li class="ui-col ui-flex ui-flex-pack-start">
        </li>
        <li class="ui-col ui-flex ui-flex-pack-center">
            <h1>阿福易购</h1>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-end">
            <a data-href="/search"><i class="ui-icon-search"></i></a>
        </li>
    </ul>
</header>


<footer class="ui-footer af-footer" >
    <ul class="ui-tiled">
        <li class="current " data-href="/"><i class="ui-icon-hall"></i><div class="menu">首页</div></li>
        <li data-href="/cat"><i class="ui-icon-scan"></i><div class="menu">分类</div></li>
        <li data-href="/cart"><i class="ui-icon-cart"></i><div class="menu">购物车</div></li>
        <li data-href="/user"><i class="ui-icon-personal"></i><div class="menu">我的</div></li>
    </ul>
</footer>
@inject('pictureService','App\Interfaces\PictureService')
@inject('categoryService','App\Interfaces\CategoryService')
@inject('adService','App\Interfaces\AdService')
@inject('activityService','App\Interfaces\ActivityService')
@inject('recommendPositionService','App\Interfaces\RecommendPositionService')

<div class="ui-container">

    <section class="J-filter-scroll ui-scroll-menu af-filter-scroller">
        <ul class="ui-scroll-menu-nav" >
            <li data-href="/" class="current">全部</li>
            @foreach($categoryService->top() as $cat)
            <li data-href="/cat/{{$cat->cat_id}}">{{$cat->cat_name}}</li>
            @endforeach

        </ul>
    </section>


    <section class="ui-slider">
        <ul class="ui-slider-content" style="width: 300%">
            @if($adService->get('index_focus'))
            @foreach($adService->get('index_focus') as $ad)
            <?php if(isset($ad->m_url)&&explode('/',$ad->m_url)[2]){ $activity_id =explode('/',$ad->m_url)[2];?>
            <li data-href="/activity/detail/{{$activity_id}}"><span style="background: url('{{$pictureService::thumb($ad->m_image),1280,500}}') center no-repeat;background-size: cover;"></span></li>
            <?php } else ?>
            <li data-href="/"><span style="background: url('{{$pictureService::thumb($ad->m_image),1280,500}}') center no-repeat;background-size: cover;"></span></li>
            @endforeach
            @endif
        </ul>
    </section>

    <section class="ui-activity">
        <ul class="ui-grid-halve">
        @foreach($activityService->getRecommendActivity() as $key=>$activity)
            @if($key<2)
            <li data-href="/activity/detail/{{$activity->id}}">
                <div class="ui-grid-halve-img">
                    <span style="background-image:url('{{$pictureService::thumb($activity->m_activity_thumb),600,600}}'); "></span>
                </div>
            </li>
            @endif
        @endforeach
        </ul>
    </section>

    @foreach($recommendPositionService->getAllRecommendPosition() as $key=>$cat)
    @if(strstr($cat->identification,'index_recommend_cat_'))
    <?php $cat_id =explode('_',$cat->identification)[3]; //dd($cat);?>
    <section class="ui-rec-category">
        <h2 data-href="/cat/{{$cat_id}}" class="ui-arrowlink af-border-b">{{$cat->name}}</h2>
        <?php
        $recommendGoods = $recommendPositionService->getRecommendGoods($cat->identification)->toArray();//dd($recommendGoods);
        $count = count($recommendGoods);
        $first = $recommendPositionService->getRecommendGoods($cat->identification)->first();//dd($first);
        //dd($recommendPositionService->getRecommendGoods($cat->identification));
        ?>
        <ul class="ui-row">
            @if($first)
            <li data-href="/goods/show/{{$first->link}}" class="ui-col ui-col-40">
                <div class="ui-rec-category-img af-border-r">
                    <span style="background-image:url('{{$pictureService::thumb($first->m_picture),480,780}}')"></span>
                </div>
            </li>
            @if($count>1)
            <li class="ui-col ui-col-60">

                <ul class="ui-row af-border-b">
                   <?php for($k=1;$k<$count;$k++){ ?>
                    <li data-href="/goods/show/{{$recommendGoods[$k]['link']}}" @if($k%2==0) class="ui-col ui-col-50" @else class="ui-col ui-col-50 af-border-r" @endif>
                        <div class="ui-rec-category-img-tb">
                            <span style="background-image:url('{{$pictureService::thumb($recommendGoods[$k]['m_picture']),400,396}}')"></span>
                        </div>
                    </li>
                    <?php if($k==2){$k = $count+1;}} ?>
                </ul>
                @if($count>2)
			    <ul class="ui-row">
                    <?php for($k=3;$k<$count;$k++){?>
                    <li data-href="/goods/show/{{$recommendGoods[$k]['link']}}" @if($k%2==0) class="ui-col ui-col-50" @else class="ui-col ui-col-50 af-border-r" @endif>
                        <div class="ui-rec-category-img-tb">
                            <span style="background-image:url('{{$pictureService::thumb($recommendGoods[$k]['m_picture']),400,396}}')"></span>
                        </div>
                    </li>
                    <?php if($k==4){$k = $count+1;}} ?>
                </ul>
                @endif
            </li>
            @endif
            @endif
        </ul>
    </section>
    @endif

    @endforeach


    <section class="ui-rec-goods">
        <h2 class="ui-arrowlink">爆品推荐</h2>
        <ul id="scrollLoadGoods" data-url="/get_goods" class="ui-rec-goods-item">
            <template class="af-hide" id="goodsTpl">
             <li class="${class}">
                <div class="ui-goods-card">
                    <div data-href="/goods/show/${relation_id}" class="ui-grid-halve-img af-border-b">
                        <span style="background-image:url(${m_picture})"></span>
                    </div>
                    <div class="ui-goods-info">
                        <h3 data-href="/goods/show/${relation_id}" class="ui-nowrap">${title}</h3>
                        <p><span class="shop-price">¥${shop_price}</span><del class="market-price">¥${market_price}</del></p>
                    </div>
                </div>
            </li>
            </template>
            @foreach($recommendPositionService->getRecommendByPage('index_baopin',1) as $key=>$recommendGoods)
            <li @if($key%2==0) class="l" @else class="r" @endif>
                <div class="ui-goods-card">
                    <div data-href="/goods/show/{{$recommendGoods->relation_id}}" class="ui-grid-halve-img af-border-b">
                        <span style="background-image:url('{{$pictureService::thumb($recommendGoods->m_picture),254,254}}')"></span>
                    </div>
                    <div class="ui-goods-info">
                        <h3 data-href="/goods/show/{{$recommendGoods->relation_id}}" class="ui-nowrap">{{$recommendGoods->title}}</h3>
                        <p><span class="shop-price">{{$recommendGoods->shop_price}}</span><del class="market-price">{{$recommendGoods->market_price}}</del></p>
                    </div>
                </div>
            </li>
            @endforeach
        </ul>

        <div class="ui-loading-wrap">
            <p>正在加载中...</p>
            <i class="ui-loading"></i>
        </div>
    </section>


</div>
<script src="{{ asset('/build/lib/zepto.min.js') }}"></script>
<script src="{{ asset('/build/js/frozen.js') }}"></script>
<script src="{{ asset('/build/js/app.min.js') }}"></script>
</body>
</html>